package com.meihua.shellapp.fragment;


import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.RelativeLayout;

import com.meihua.shellapp.R;
import com.meihua.shellapp.activity.SearchActivity;
import com.meihua.shellapp.adapter.PioneerViewPagerAdapter;
import com.meihua.shellapp.base.BaseFragment;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 创客大学
 */
public class PioneerFragment extends BaseFragment {
    @Bind(R.id.goods_tabs)
    TabLayout mTabs;
    @Bind(R.id.goods_vpager)
    ViewPager mViewpager;
    @Bind(R.id.top_rl_search)
    RelativeLayout mRlSearch;
    private PioneerViewPagerAdapter adapter;

    @Override
    protected void initView() {
        mRlSearch.setVisibility(View.VISIBLE);

        /*设置tab+vp*/
        if (adapter == null) {
            adapter = new PioneerViewPagerAdapter(getChildFragmentManager());
            mViewpager.setAdapter(adapter);
        } else {
            adapter.notifyDataSetChanged();
        }
        mTabs.setupWithViewPager(mViewpager);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_pioneer;
    }

    @OnClick(R.id.top_rl_search)
    public void onViewClicked() {
        /*搜索中心界面*/
        startActivity(new Intent(getActivity(), SearchActivity.class));
    }
}
